<?php
/**
 * ErrorHandler
 * Samble error handling class
 *
 * @author Lim Afriyadi
 * @version pre-alpha
 * @package Samble
 * @subpackage err
 * @license GNU/GPL
 */
class ErrorHandler extends Err
{
    /**
     * Class single instance.
     * @var object
     * @static
     */
    static $o_Instance;
    /**
     * Err status.
     * @var boolean
     */
    var $b_Err_Exists = false;
    /**
     * Initialize and return the class own instance.
     * @return object
     */
    public static function getInstance()
    {
        if( !self::$o_Instance )
        {
            self::$o_Instance = new ErrorHandler();
        }
        return self::$o_Instance;
    }
    /**
     * Set and save an error.
     * @param string $s_Err_Msg
     */
    public static function error( $s_Err_Msg )
    {
        self::$o_Instance->setError( $s_Err_Msg );
        if( !self::$o_Instance->b_Err_Exists ) self::$o_Instance->b_Err_Exists = true;
    }
    /**
     * Throw the error to standard out.
     * @return string || false
     */
    public static function displayError() {
        if( self::$o_Instance->b_Err_Exists )
        {
            echo self::$o_Instance->getError();
            self::$o_Instance->clearError();
            self::$o_Instance->b_Err_Exists = false;
        }
        else
        {
            return false;
        }
    }
}
?>
